]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add magic "js " prefix to runDialog to run arbitrary JavaScript
authorColin Walters <walters@verbum.org>
Wed, 8 Jul 2009 21:30:09 +0000 (17:30 -0400)
committerColin Walters <walters@verbum.org>
Wed, 8 Jul 2009 21:30:09 +0000 (17:30 -0400)
This is useful for debugging things; e.g. you can "js Meta.quit(0)"
to exit the WM, "js Shell.Global.get().<whatever>..." etc.

js/ui/runDialog.js

index eafdaef34ffa2bddb75f2f4b843065fa0c0df678..fc5493ad87fae3ce2d4b9d70e571036f9a531c60 100644 (file)
@@ -79,7 +79,22 @@ RunDialog.prototype = {
     },
 
     _run : function(command) {
-        if (command == 'restart') {
+        if (command.slice(0, 3) == 'js ') {
+            let commandHeader = "const Clutter = imports.gi.Clutter; " +
+                                 "const GLib = imports.gi.GLib; " +
+                                 "const Gtk = imports.gi.Gtk; " +
+                                 "const Mainloop = imports.mainloop; " +
+                                 "const Meta = imports.gi.Meta; " +
+                                 "const Shell = imports.gi.Shell; " +
+                                 "const Main = imports.ui.main; ";
+            let cmd = commandHeader + command.substring(2);
+            try {
+                let result = eval(cmd);
+                log("" + result);
+            } catch (e) {
+                log(e);
+            }
+        } else if (command == 'restart') {
             let global = Shell.Global.get();
             global.reexec_self();
         } else if (command) {